package org.yw.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.yw.dto.Dto;
import org.yw.fallback.LoginServiceFallBack;
import org.yw.pojo.DmUser;

import javax.servlet.http.HttpServletRequest;

@FeignClient(value = "greatsearch-auth-provider",fallback = LoginServiceFallBack.class)
public interface LoginService {

    /**
     * 用户登陆
     * @param phone
     * @param password
     * @return
     */
    @PostMapping("login")
    Dto doLogin(@RequestParam("phone")String phone,
                       @RequestParam("password")String password);

    /**
     * 用户注册
     * @param phone
     * @param password
     * @param vcode
     * @return
     */
    @PostMapping("register")
    public Dto register(@RequestParam("phone")String phone,
                        @RequestParam("password")String password,
                        @RequestParam("vcode")String vcode);

    /**
     * 验证用户名存在否
     * @param phone
     * @return
     */
    @PostMapping("checkemail")
    public Dto checkPhone(@RequestParam("phone")String phone);

    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @PostMapping("sendcode")
    public Dto sendCode(@RequestParam("phone")String phone);

    /**
     * 根据token查询用户个人信息
     * @param request
     * @return
     */
    @PostMapping("queryUserInfoByToken")
    public Dto queryUserInfoByToken(HttpServletRequest request);

    /**
     * 更新用户个人信息
     * @param user
     * @return
     */
    @PostMapping("modifyUserInfo")
    public Dto modifyUserInfo(@RequestBody DmUser user);
}
